<?php
/***************************************************************************
 *                               verifypass.php
 *                            -------------------
 *   copyright            : (C) 2004 Vallheru Team based on Gamers-Fusion ver 2.5
 *   email                : thindil@users.sourceforge.net
 *
 ***************************************************************************/

/***************************************************************************
 *
 *       This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 ***************************************************************************/

function verifypass($string,$action) {
global $smarty;
//Sprawdzenie dlugosci hasla
    $test = strlen($string);
    if ($test < 5) {
	    if ($action == 'register') {
            $smarty -> assign ("Error", "Haslo musi posiadac co najmniej 5 znakow.");
            $smarty -> display ('error.tpl');
            $smarty -> display('foot.tpl');
            exit;
        } else {
	        error("Haslo musi posiadac co najmniej 5 znakow.");
        }
	}
	
//Sprawdzenie czy haslo zawiera litery oraz cyfry
    $test = eregi(".[a-z]", $string);
    $test1 = ereg(".[0-9]", $string);
    if (empty($test) || empty($test1)) {
	    if ($action == 'register') {
            $smarty -> assign ("Error", "Haslo musi skladac sie z liter oraz cyfr (przynajmniej po jednej).");
            $smarty -> display ('error.tpl');
            $smarty -> display('foot.tpl');
            exit;
        } else {
	        error("Haslo musi skladac sie z liter oraz cyfr (przynajmniej po jednej).");
        }
	}
	
//Sprawdzanie czy haslo zawiera duze litery
    if (!ereg("[[:upper:]]", $string)) {
	    if ($action == 'register') {
            $smarty -> assign ("Error", "Haslo musi posiadac co najmniej jedna duza litere.");
            $smarty -> display ('error.tpl');
            $smarty -> display('foot.tpl');
            exit;
        } else {
	        error("Haslo musi posiadac co najmniej jedna duza litere.");
        }
	}
}	    		    
